﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;
using WxPayAPI;
using Models;
using Newtonsoft.Json;
using System.IO;
using System.Xml;
using Common.Wx;

/// <summary>
/// SmsTempleMsg 的摘要说明
/// </summary>
public class SmsTempleMsg
{

    public string sort, smallName, sortrepair;

    Entities db = new Entities();

    public SmsTempleMsg()
    {
        //
        // TODO: 在此处添加构造函数逻辑
        //
    }


    public string SendTemplate(string openId, string templateId, object data, string url, string topcolor = "#173177")
    {
        JavaScriptSerializer Jss = new JavaScriptSerializer();
        var msgData = new
        {
            touser = openId,
            template_id = templateId,
            topcolor = topcolor,
            url = url,
            data = data
        };
        string postData = Jss.Serialize(msgData);
        var token = WxHelper.IsExistAccess_Token();

        return CommonMethod.WebRequestPostOrGet("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+token, postData);

    }




}
